<template>
  <div class="login-wrap">
    <div class="login-main">
      <div class="login-header">
        <div class="login-logo">
          <img src="../../assets/img/login-logo.png" alt />
        </div>
        <div class="l-title">华风集团媒体资源运营平台</div>
      </div>
      <div class="login-cell">
        <div class="login-inner">
          <div class="r-rows">
            <div class="r-name">注册邮箱</div>
            <el-input style="width:200px;" v-model="email"></el-input>
            <el-button style="margin-left:30px;" @click.native="getcode">获取验证码</el-button>
          </div>
          <div class="r-rows">
            <div class="r-name">邮箱验证码</div>
            <el-input v-model="code" style="width:200px;"></el-input>
          </div>
          <div class="r-rows">
            <div class="r-name">重置密码</div>
            <el-input v-model="password" maxlength="18" type="password" style="width:200px;"></el-input>
          </div>
          <div class="r-rows">
            <div class="r-name">输入密码</div>
            <el-input v-model="pwd" maxlength="18" type="password"  style="width:200px;"></el-input>
          </div>
          <div class="l-button">
            <button type="button" class="btn btn-lg btn-login" @click="setpossword">提交</button>
          </div>
          <div class="l-end clearfix" style="margin-top:30px;">
            <!-- <el-radio size="18" label="2">记住密码</el-radio> -->
            <!-- <div class="l-link" @click="gologin">去登录</div> -->
						<el-button class="l-link" type="text" @click="gologin">去登录</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Cookies from "js-cookie";
import { reset_pwd ,setreset_pwd} from "../../api/System.js";
// import { validUsername } from '@/utils/validate'
import { mapMutations } from "vuex";
// import {Input } from 'element-ui'
export default {
  name: "Login",
  // components: { LangSelect, SocialSign },
  data() {
    return {
      email: "",
      code: "",
			pwd: "",
			password:''
    };
  },
  watch: {},
  created() {
    // window.addEventListener('storage', this.afterQRScan)
  },
  computed: {},
  mounted() {},
  destroyed() {
    // window.removeEventListener('storage', this.afterQRScan)
  },
  methods: {
		setpossword(){
				if(!this.email){
				this.$message({
					message:'邮箱不能为空',
					type:'warning'
				})
				return
			}
			if(!this.code){
				this.$message({
					message:'验证码不能为空',
					type:'warning'
				})
				return
			}
				if(this.password.length<6){
				this.$message({
					message:'密码长度6~18位',
					type:'warning'
				})
				return
			}
      if(this.password!==this.pwd){
				this.$message({
					message:'密码不一致',
					type:'warning'
				})
				this.password=''
				this.pwd=''
			}
			var data={
				email:this.email,
				code:this.code,
				pwd:this.pwd
			}
				setreset_pwd(data).then(res=>{
					if(res.code==200){
						this.$message({
							message:'密码重置成功',
							type:'success'
						})
						this.$router.push({
        path: "/login"
      });
					}
				})
		},
    getcode() {
      reset_pwd({email:this.email}).then(res => {
				console.log(res);
				if(res.code==200){
					this.$message({
						message:'验证码已发送至你的邮箱',
						type:'success'
					})
				}
      });
    },
    gologin() {
      this.$router.push({
        path: "/login"
      });
    }
  }
};
</script>



<style lang="scss" scoped>
.login-wrap {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 9;
  // background-image: ../../assets/img/bg.jpg;
  background: url("../../assets/img/bg.jpg");
  // background-image: '../../assets/img/hdbg.jpg';
  // background: url(../../assets/img/bg.jpg) center no-repeat;
  background-size: cover;
}
.l-link {
  float: right;
  color: #062c87;
  font-size: 16px;
}
.login-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 0;
  background: url("../../assets/img/hdbg.png");
  background-position: bottom;
  background-repeat: no-repeat;
  // background: url('../../assets/img/hdbg.jpg') center bottom no-repeat;
}
.login-logo {
  margin-bottom: 30px;
}
.l-title {
  font-size: 36px;
  font-weight: bold;
  line-height: 1;
}
.login-cell {
  background-color: #ffffff;
  width: 540px;
  height: 420px;
  margin: 0 auto;
}
.login-inner {
  padding: 70px 35px;
  margin-top: -10px;
}
// .clearfix{
//   width: 100%;
//   display: flex;
//   justify-content: space-between;
// }
.l-row {
  position: relative;
  margin-bottom: 30px;
  display: flex;
}
.l-row .form-control {
  border: 1px solid #d9d9d9;
  height: 50px;
  line-height: 48px;
  padding: 0 45px;
  width: 100%;
  font-size: 15px;
  box-shadow: 0 0 0 transparent;
  border-radius: 40px;
}
.l-row .form-control:focus {
  border: 1px solid #1168c7;
  box-shadow: 0 0 10px #83a7c8;
}
.l-row .form-control:focus + .iconfont {
  color: #1168c7;
}
.l-row .iconfont {
  display: inline-block;
  position: absolute;
  width: 30px;
  line-height: 30px;
  height: 30px;
  text-align: center;
  left: 12px;
  top: 50%;
  margin-top: -15px;
  font-size: 20px;
}
.l-row .iconfont {
  color: #999999;
}
.l-button .btn-login {
  margin-top: 30px;
  padding: 15px;
  font-size: 16px;
  background-color: #0055a4;
  background: -webkit-linear-gradient(#005ab0, #014c90); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(#005ab0, #014c90); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(#005ab0, #014c90); /* Firefox 3.6 - 15 */
  background: linear-gradient(#005ab0, #014c90); /* 标准的语法 */
  box-shadow: 2px 5px 5px #83a7c8;
  width: 100%;
  border-radius: 40px;
  color: #ffffff;
  outline: none;
}
.r-rows {
  width: 100%;
  display: flex;
  align-items: center;
  margin-top: 10px;
  .r-name {
    width: 110px;
  }
}
</style>
